/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: qian
 * Date: 2023-01-03
 * Time: 11:19
 */
//单例模式
//饿汉模式
class Singleton{
    private static Singleton instance=new Singleton();
    public static Singleton getInstance(){
        return instance;
    }
    //防止创建新对象
    private Singleton(){

    }
}
public class Demo1 {
    public static void main(String[] args) {
        //获取单例对象
        Singleton instance=Singleton.getInstance();
    }
}
